function my$(id) {
    return document.getElementById(id);
  }

function Q5() {
    var temp = my$("Q5");
    var i = Math.floor(Math.random()*temp.length)
    temp[i].selected = true;

}

// Q6
var Q6 = my$("Q6");
Q6.onfocus = function() {
    if(this.value === "请输入搜索关键字"){
        this.value = "";
        this.style = "color:black"
    }
}

Q6.onblur = function () {
    if (this.value === "" || this.value === "请输入搜索关键字") {
      this.value = "请输入搜索关键字";
      this.style = "color:gray"
    }
  };

function Q7() {
    var temp = my$("er");
    er.className = er.className.replace("hide","show")
    er.innerText = "我是二维码,我的class名有erweima, show"
}

var inputLists = document.getElementsByClassName("input8")
for (var i = 0;i < inputLists.length; i++) {
    inputLists[i].onfocus = function() {
        for (var j = 0; j < inputLists.length; j++){
            inputLists[j].style.backgroundColor = "white"
        }
        this.style.backgroundColor = "gray"
    }
    inputLists[i].onblur = function() {
        for (var j = 0; j < inputLists.length; j++){
            inputLists[j].style.backgroundColor = "white"
        }
    }
}

// Q9
function Q9() {
    var Q9List = my$("Q9List");
    var text = my$("Q9");
    console.log(text.value)
    if (text.value !== ""){
        var li = document.createElement("li");
        li.innerText = text.value;
        Q9List.appendChild(li);
        text.value = "";
    }
}

// Q10
var Q10 = my$("Q10List");
Q10.onclick = function(e){
    console.log(e.target.style.backgroundColor)
    e.target.style.backgroundColor = "red";
}

function Q12() {
    let btn = my$("Q12btn")
    btn.setAttribute("disabled",true);
    setTimeout(function(){
        btn.removeAttribute("disabled");
    },2000)

}



